/*
 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#pragma once

#include <stdint.h>
#include "driver/rmt_encoder.h"

#ifdef __cplusplus
extern "C"
{
#endif
    typedef enum rmt_message_symbol_num_e
    {
        NEC_CLASS_NUM = 34,
        NEC_REPEAT_CLASS_NUM = 2,
        CUSTOM_CLASS_NUM = 58,
    } rmt_message_symbol_num_t;

    typedef enum rmt_leading_type_e
    {
        NEC_LEADING_CLASS,
        CUSTOM_LEADING_CLASS,
    } rmt_leading_type_t;

    /**
     * @brief Type of IR NEC encoder configuration
     */
    typedef struct
    {
        uint32_t resolution; /*!< Encoder resolution, in Hz */
    } ir_nec_encoder_config_t;

    /**
     * @brief Create RMT encoder for encoding IR NEC frame into RMT symbols
     *
     * @param[in] config Encoder configuration
     * @param[out] ret_encoder Returned encoder handle
     * @return
     *      - ESP_ERR_INVALID_ARG for any invalid arguments
     *      - ESP_ERR_NO_MEM out of memory when creating IR NEC encoder
     *      - ESP_OK if creating encoder successfully
     */
    esp_err_t rmt_new_ir_nec_encoder(const ir_nec_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder);


bool nec_parse_frame(rmt_symbol_word_t *rmt_nec_symbols, uint8_t *command);
bool custom_parse_frame(rmt_symbol_word_t *rmt_nec_symbols, uint8_t *dummy_array);
bool nec_parse_frame_repeat(rmt_symbol_word_t *rmt_nec_symbols);
#ifdef __cplusplus
}
#endif
